# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   selenium_self
# FileName:      case_runner.py
# Author:       test_liu
# Datetime:     2024/10/19 上午10:59
# Description: 用例执行层
# ---------------------------------------------------------------------------
import os
import unittest

import unittestreport

from WebTest2.WebTest.common.read_local_ini import ReadLocalIni

if __name__ == '__main__':
    # 创建suite
    suite = unittest.TestSuite()
    # 创建loader
    loader = unittest.TestLoader()
    # 获取用例层的路径
    ini = ReadLocalIni()
    # 单人用户用例测试，最后一个写自己的用例目录
    test_dir = os.path.join(ini.main_path, "test_case", "test_han")
    # 多人用户用例测试
    # test_dir = os.path.join(ini.main_path, "test_case")
    # 获取报告的路径
    html = ini.get_report("html")
    # 加载用例
    suite.addTests(loader.discover(test_dir, "test*.py"))
    # 创建runner
    runner = unittestreport.TestRunner(
        suite,
        filename="毕设项目测试.html",
        report_dir=html,
        title='测试报告',
        tester='test_liu',
        desc="毕设项目测试生成的报告",
        templates=1
    )
    runner.run()
